package com.sky.financelake.viewmodels.remote;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.sky.financelake.bean.dto.SimpleStockDto;
import com.sky.financelake.bean.dto.StockDto;
import com.sky.financelake.bean.param.StockParam;
import com.sky.financelake.retrofit.ApiResponse;
import com.sky.financelake.retrofit.StockRepository;
import com.sky.financelake.viewmodels.BaseViewModel;

import java.util.List;

public class StockViewModel extends BaseViewModel {
    private MutableLiveData<ApiResponse<List<StockDto>>> mutableLiveData;
    private MutableLiveData<ApiResponse<List<SimpleStockDto>>> mutableLiveDataSimple;
    private StockRepository stockRepository;

    public StockViewModel() {
        if (mutableLiveData != null) {
            return;
        }
        stockRepository = StockRepository.getInstance();
    }

    public StockRepository getStockRepository() {
        return stockRepository;
    }

    public LiveData<ApiResponse<List<StockDto>>> getStockListLiveData() {
        if (mutableLiveData == null) {
            mutableLiveData = new MutableLiveData<ApiResponse<List<StockDto>>>();
        }
        return mutableLiveData;
    }

    public LiveData<ApiResponse<List<SimpleStockDto>>> getSimpleStockListLiveData() {
        if (mutableLiveDataSimple == null) {
            mutableLiveDataSimple = new MutableLiveData<ApiResponse<List<SimpleStockDto>>>();
        }
        return mutableLiveDataSimple;
    }



    public void getStockPagingList(StockParam param) {
        stockRepository.getStockPagingList(mutableLiveData, param);
    }


    public void getRelativeStockByPlates(String plates) {
        stockRepository.getRelativeStockByPlates(mutableLiveDataSimple, plates);
    }
}
